package https

import (
	"gitee.com/lailonghui/vehicle-supervision-framework/pkg/services"
	"github.com/Yamashou/gqlgenc/client"
	"net/http"
)

// 新建默认配置的客户端
func NewDefaultClient() *http.Client {
	return http.DefaultClient
}

// 通过配置新建客户端
func NewClientByConfig(config *services.EndpointConfig) *http.Client {
	c := http.Client{}
	if config == nil {
		return &c
	}
	if config.Timeout != nil {
		c.Timeout = *config.Timeout
	}

	return &c
}

// gqlgenc 默认http请求配置
func GqlgencDefaultHttpRequestOptions() []client.HTTPRequestOption {
	return DefaultHttpRequestOptions()
}

func DefaultHttpRequestOptions() []client.HTTPRequestOption {
	return []client.HTTPRequestOption{AuthorizationOption()}
}

// 通过配置信息，设置options
func HttpRequestOptionsByConfig(config *services.EndpointConfig) (options []client.HTTPRequestOption) {
	options = DefaultHttpRequestOptions()
	if config == nil {
		return
	}

	return

}
